class Virus < ActiveRecord::Base
  belongs_to :virus_type
  def self.infection
    @computer = Computer.find(:first, :order => "RAND()")
    @virus = self.find(:first, :order => "RAND()")
    
    event_tab = { "information" => "infection par #{@virus.name}",
              "state" => 1,
              "computer_id" => @computer.id,
              "type_event_id" => 3
            }
      event = Event.new(event_tab)
    if event.save
       puts "Un nouvelle infection a été détecté"
      #flash[:incident]= "Un nouvelle incident a été détecté"
      end
  end
end
